class Solution
{
public:
    bool solve(string A, string B)
    {
        if (A == B)
            return true;
        if (A.size() != B.size())
            return false;
        A += A;
        if (A.find(B) != -1)
            return true;
        else
            return false;
    }
};